package cn.cream4u.ksks.aaController;

import cn.cream4u.ksks.abService.StuServ;
import cn.cream4u.ksks.adPojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class StuController {
    @Autowired
    StuServ stuServ;
//int page, int pagesize, String name, int educationId, int number, int classId) {

    @GetMapping("/student")
    Result getStudent(Integer page, Integer pageSize, String name, Integer educationId, Integer number, Integer classId){
        StuPojo2 kk =  stuServ.selectPojos(page,pageSize,name,educationId,number,classId);
        return Result.success(kk);
    }

    @GetMapping("/student/{id}")
    Result getStudentById(@PathVariable Integer id){
        return Result.success(stuServ.selectPojoById(id));
    }

    @PutMapping("/student")
    Result updateStudent(@RequestBody StuPojo3 stuPojo){
        System.out.println(stuPojo);
        stuServ.updatePojo(stuPojo);
        return Result.success("null");
    }
    @PostMapping("/student")
    Result insertStudent(@RequestBody StuPojo4 pojo){
        stuServ.insertStu(pojo);
        return Result.success("null");
    }
    @DeleteMapping("/student/{kks}")
    Result deleByIds(@PathVariable Integer[] kks){
        stuServ.deleByIds(kks);
        return Result.success("null");
    }
    @RequestMapping("/student")
    Result updateStudent(int id,int disciplineScore){
        stuServ.disdis(id,disciplineScore);
        return Result.success("null");
    }
}
